#ifndef __GRID_H_
#define __GRID_H_

#include"main.h"

#define START_MAIN_INFO 1
#define END_MAIN_INFO 2
#define START_CELL 3
#define END_CELL 4
#define END_FILE 5

class Cell{
public:
	Cell( void ){
		FLAG_need_callback = false;
		last_time = -1;
	};
	int coord_x, coord_y;
	double T_start;
	double h_x, h_y;
	double n;
	int type;
	int FLAG_need_callback;
	clock_t last_time;
};

class Grid{
public:
	Grid( void );
	int size_x, size_y;
	Cell*** mass_pcells;
	double T_1;
	double T_2;
	double knudsen_number;
	double h_standart;
	double n1_a, n1_b, n2_a, n2_b;
	void NewGrid( int size_x, int size_y );
	void FillCell( int coord_x, int coord_y, int type,
		double T_start, double h_x, double h_y, double n ... );
	void FillCell( int coord_x, int coord_y, int type,
		double T_start, double h_x, double h_y, int sp_start_x, int sp_start_y, double n ... );
	void FillCell( int coord_x, int coord_y, int type,
	double T_start, double h_x, double h_y, int sp_start_x, int sp_start_y, ... );
	void FillCellWithoutN( int coord_x, int coord_y, int type,
		double T_start, double h_x, double h_y );
	void Set_n( int coord_x, int coord_y, int sp_start_x, int sp_start_y, double n );
	void DeleteCell( int coord_x, int coord_y );
	void DeleteGrid( void );
	void GenerateSquareGrid( int sp_start_x, int sp_start_y, int sp_size_x, int sp_size_y );
	void GenerateHTipeGrid( int sp_start_x, int sp_start_y, int sp_size_x, int sp_size_y,
		int d, int h, int depth_of_the_gap, int gapth_quantity );
void GenerateBigContainers( int sp_start_x, int sp_start_y, int sp_size_x, int sp_size_y,
	int d, int h, int depth_of_the_gap );
	void OutToFile( const char* f_name );
	void CreateFromFile( const char* f_name );
	double GetHx( int i, int j, double cont_size_x, double cont_size_y, double h_standart, double h_big_x );
	double GetHy( int i, int j, double cont_size_x, double cont_size_y, double h_standart, double h_big_y );
	double GetHx2( int i, int j, double cont_size_x, double cont_size_y, double h_standart, double h_big_x );
	double GetHy2( int i, int j, double cont_size_x, double cont_size_y, double h_standart, double h_big_y );

	struct MAIN_INFO{
		int size_x, size_y;
		int gaps_start_x, gaps_start_y;
		int gaps_quantity;
		int d, h;
		int depth_of_the_gap;
		int sp_start_x, sp_start_y;
		int sp_size_x, sp_size_y;
		int l_sp;
	} main_info;
	struct CELL{
		int coord_x, coord_y;
		double T_start;
		double h_x, h_y;
		double n;
		int type;
	};
};

extern Grid* Grid_;

#endif